<template>
    <div>
        <h2>房价修改</h2>
        <table class="table table-bordered">
<tr>
    <td align="right">房型名称</td>
    <td><input type="text" v-model="state.hName" /></td>
</tr>
<tr>
    <td align="right">房价</td>
    <td><input type="text" v-model="state.price" /></td>
</tr>

<tr>
    <td align="right">早餐数量</td>
    <td><input type="text" v-model="state.num" /></td>
</tr>
<tr>
    <td align="right">上线人数</td>
    <td><input type="text" v-model="state.number" /></td>
</tr>
<tr>
    <td align="right"></td>
    <td><input type="button" value="录入" @click="upd" /></td>
</tr>
</table>
    </div>
</template>

<script setup lang="ts">
import { reactive,toRefs } from 'vue';
import { useRouter,useRoute } from 'vue-router';
import axios from 'axios';
const router=useRouter();
let data=reactive({
    state:{
        hName:'',
        price:'',
        num:'',
        number:'',
    }
})

let{state}=toRefs(data)

const upd=()=>{

if(state.value.hName==""){
    alert("房型名称不能为空")
    return;
}
if(state.value.price==""){
    alert("房价不能为空")
    return;
}
    let obj={
        id: 1,

    }
    axios({
        url:'/api/HouseMoney/updateMoney',
        method:'post',
        data:obj
    })
    .then(res=>{
        console.log(res)
        if(res.data==1){
            alert("修改成功")
            router.push("/HMlist")
        }
        else{
            alert("修改失败")
            return;
        }
    })
    .catch(err=>{
        console.log(err)
    })
}
</script>

<style scoped>

</style>